﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LibraryMusicStore;

namespace AppMusicStore
{
    internal class Common
    {
        //internal static bool TestConnection(MusicStoreEntities db)
        //{
        //    if (!db.DatabaseExists())
        //    {
        //        string str = "Kết nối cơ sở dữ liệu thất bại";
        //        string caption = "Thông báo lỗi";

        //        System.Windows.Forms.MessageBox.Show(str, caption, 
        //            System.Windows.Forms.MessageBoxButtons.OK, 
        //            System.Windows.Forms.MessageBoxIcon.Error);
                
        //        return false;
        //    }
        //    return true;
        //}

        internal static void ShowErrorBox(string p)
        {
            string str = "Lỗi : " + p;
            string caption = "Thông báo lỗi";

            System.Windows.Forms.MessageBox.Show(str, caption, 
                System.Windows.Forms.MessageBoxButtons.OK, 
                System.Windows.Forms.MessageBoxIcon.Error);
        }

        internal static void ShowInfomationBox(string p)
        {
            string str = p;
            string caption = "Hoàn tất";

            System.Windows.Forms.MessageBox.Show(str, caption,
                System.Windows.Forms.MessageBoxButtons.OK,
                System.Windows.Forms.MessageBoxIcon.Information);
        }

        internal static System.Windows.Forms.DialogResult ShowQuestionBox(string p, string p_2)
        {
            string str = p;
            string caption = "Xác nhận";

            if (p_2 == "yesnocancel")
            {
                return System.Windows.Forms.MessageBox.Show(str, caption,
                System.Windows.Forms.MessageBoxButtons.YesNoCancel,
                System.Windows.Forms.MessageBoxIcon.Question,
                System.Windows.Forms.MessageBoxDefaultButton.Button1);
            }

            return System.Windows.Forms.MessageBox.Show(str, caption,
            System.Windows.Forms.MessageBoxButtons.OKCancel,
            System.Windows.Forms.MessageBoxIcon.Question,
            System.Windows.Forms.MessageBoxDefaultButton.Button1);
        }

        internal static decimal GetVAT(decimal value)
        {
            return 1 + value / 100;
        }
    }
}
